/* 
  防抖：在规定时间内触发同一事件时，只会触发一次，
*/


const debounce = function (fn, delay) {
  let timer = null
  return function () {
    if (timer) {
      clearTimeout(timer)
      timer = null
    }
    timer = setTimeout(fn, delay)
  }
}